package com.jt.tenant.conn;

import com.jt.tenant.app.JTApplication;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * 获取APP TOKEN信息
 */
@HttpInlet(Conn.INLET_BINDING_EQUPI)
public class GetBindingEquip extends JTAsyGet<GetBindingEquip.Info> {

    public String token = JTApplication.jtPreferences.readToken();

    public String obd_id = JTApplication.jtPreferences.readOdbID();

    public GetBindingEquip(String obd_id, AsyCallBack<Info> asyCallBack) {

        super(asyCallBack);

        this.obd_id = obd_id;

    }

    @Override
    protected Info parser(JSONObject object) {

        JSONObject apiTYF = object.optJSONObject("apiTYF");

        JSONObject head = apiTYF.optJSONObject("head");

        Info info = new Info();

        info.msg = head.optString("msg");

        if (info.msg.equals("000")) {

            JSONObject body = apiTYF.optJSONObject("body");

            JSONObject obd = body.optJSONObject("obd");

            info.activatState = obd.optString("activatState"); //1是激活 2 是激活并绑定 !=0  就是激活

            info.tag = obd.optString("tag");// 1是关爱版,0 是标准版

            info.cardAvailableTime = obd.optString("cardAvailableTime"); //套餐剩余时间

            info.wifiType = obd.optString("wifiType");

            info.wifiPassword = obd.optString("wifiPassword");

        }

        return info;

    }

    public static class Info {

        public String msg;

        public String activatState, tag, cardAvailableTime,wifiType,wifiPassword;
    }

}
